package com.zhuozhou.jdyc.main.menu.activity;

import android.os.Bundle;
import android.text.Html;

import com.zhuozhou.jdyc.R;
import com.zhuozhou.jdyc.base.BaseToolbarActivity;
import com.zhuozhou.jdyc.base.BaseViewModel;
import com.zhuozhou.jdyc.databinding.DownloadTestBinding;
import com.zhuozhou.jdyc.util.networkTools.NetworkStateUtil;
import com.zhuozhou.jdyc.util.update.DownloadManger;
import com.zhuozhou.jdyc.wight.dialog.ConfirmDialog;

/**
 * Create by CherishTang on 2020/3/27 0027
 * describe:
 */
public class TestDownloadActivity extends BaseToolbarActivity<BaseViewModel, DownloadTestBinding> {
    @Override
    protected int getLayoutId() {
        return R.layout.download_test;
    }

    @Override
    public String setTitleBar() {
        return "文件下载";
    }

    @Override
    public void initView() {
        addMenu("复制", R.color.theme_orange, null);
        String downloadPath = "http://softfile.3g.qq.com:8080/msoft/179/24659/43549/qq_hd_mini_1.4.apk";
        binding.tvFile.setText(Html.fromHtml("<u>mini-qq-测试.apk</u>"));
        binding.tvFile.setOnClickListener(v ->
                new ConfirmDialog(this)
                        .setMessage(NetworkStateUtil.isMobile(this) ?
                                "当前网络为数据流量，是否确定继续下载？" : "是否确定下载当前文件")
                        .setSureText("下载")
                        .setOnSureClickListener(dialog ->
                                DownloadManger.getInstance().download(this, downloadPath))
                        .builder()
                        .show());
    }

    @Override
    public void initData(Bundle bundle) {

    }

}
